/*
 * declareScaffold Construction Tool v0.9
 * http://declarescaffold.com/
 *
 * Copyright (c) 2009 Brian Yang
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *   
 * Date: 2009-11-27 17:34:21 -0500 (Fri, 27 Nov 2009)
 * Revision: 22
 */

(function($){

    $.fn.extend({
        scaffoldStyle: function(){
        

            // create drop tab
            var snippet = $('<a id="show_ds" href="#">$.declareScaffold.js installed</a><textarea class="warped_tab"></textarea>');
            $('body').prepend(snippet);
            // Todo :: create class for plugin configuration
            $('.warped_tab textarea').css({
                width: "350px",
                height: "200px"
            });
            $('.warped_tab').css({
                background: "#eee",
                position: "absolute",
                width: "auto",
                height: "200px",
                marginLeft: "850px",
            });
            
            // create functionality for toggle button
            $('#show_ds').click(function(){
              $('.warped_tab').toggle();
            }).css({fontSize:".7em",backgroundColor:"blue",color:"#fff",textDecoration:"none"});
            
            
            
            // acquire element attributes values and inject into DOM
            $('div#page_wrap *').each(function(index){
                if ($(this).attr('id')) {
                    var parent = $(this).parent().attr('tagName').toLowerCase();
                //    $('.warped_tab').prepend(parent + ' .' + $(this).attr('id') + '{}<br/>');
                }
                if ($(this).attr('class')) {
                    var parent = $(this).parent().attr('tagName').toLowerCase();
                    var parentClassName = $(this).parent().attr('class').toLowerCase();
                    // console.log(parentClassName);
                    
                    
                    $('.warped_tab').append(' .' + parentClassName + ' .' + $(this).attr('class') + '{}<br/>');


                }
            });
            





            // add opener 
            // $('body').prepend('<h1 id="opener"><a href="#">opener link</a></h1>');
            $('#opener').click(function(){
                // alert ('ds');
                
                
                function fixHeight(){
                    // console.log('inside fix height again')
                    var theHeight = $('.warped_tab').height();
                    console.log(theHeight)
                    var theTab = $('.warped_tab');
                    // $(theTab).css({                        marginTop: theHeight                    });
                
                
                };
                // fixHeight();
                
            });
            
            // acquire element tag names and append
            $('body>#wrap').children().children().each(function(index){
               // $('.warped_tab').append($(this).attr('tagName').toLowerCase() + '<br/>');
            });
            
            
            //Iterate over the current set of matched elements
            return this.each(function(){
                $('.warped_tab').click(function(){
                });
            });
            
            
            
            
            
        }
        
        
    });
    
// tester machine
function testerBot () {
  // console.log('im just for testing');
};
testerBot();
    
    
    
    
    
    
})(jQuery);

